//
//  NSData+JwCate.h
//  JwPack
//
//  Created by 陈警卫 on 2024-07-18.
//

#import <Foundation/Foundation.h>

@interface NSData (JwCate)

/// 解析JSON
- (NSDictionary *)jw_json;

/// data转16进制字符串
- (NSString *)jw_hexString;

/// data转2进制字符串
- (NSString *)jw_binaryString;

/// data转ascii字符串
- (NSString *)jw_asciiString;

/// data转ascii字符串（修正版本）
- (NSString *)jw_asciiStringCorrect;

/// 反转字节序列代码
- (NSData *)jw_dataReverse;

/// data转NSInteger
- (NSInteger)jw_integer;

/// data转int8
- (int8_t)jw_int8;

/// data转int16
- (int16_t)jw_int16;

/// data转int32
- (int32_t)jw_int32;

/// data转NSUInteger
- (NSUInteger)jw_uint:(NSUInteger)len;

/// data转uint8
- (uint8_t)jw_uint8;

/// data转uint16
- (uint16_t)jw_uint16;

/// data转uint32
- (uint32_t)jw_uint32;

/// int转data(大小端)
+ (NSData *)jw_dataWithInt:(NSInteger)value length:(NSUInteger)length;

/// int转data(大小端)
+ (NSData *)jw_dataWithInt:(NSInteger)value len:(NSUInteger)len;

/// int转data
+ (NSData *)jw_dataNtohWithInt:(NSInteger)value length:(NSUInteger)length;

/// 获取data二进制下标的值 方向右左 <-
- (NSInteger)jw_binaryWithIndex:(NSInteger)index;

/// 获取data二进制范围内值 方向右左 <-
- (NSInteger)jw_binaryWithRange:(NSRange)range;

/// md5 Data
- (NSData *)jw_md5Data;

/// md5 String
- (NSString *)jw_md5String;

/// CRC-16/CCITT-FALSE x16+x12+x5+1
- (unsigned short)jw_crc;

/// CRC-16/CCITT-FALSE x16+x12+x5+1
- (NSData *)jw_crcData;

/// CRC-16/CCITT-FALSE x16+x12+x5+1
- (NSString *)jw_crcString;

@end
